﻿using UnityEngine;
using System.Collections;

public class TestButtonCreat : MonoBehaviour {
	public  Texture   Textrue1;
	public Vector2 scrollPos = Vector2.zero;
	public string stringToEdit = "Hello World\nI've got 2 lines...";

	public  Rect  WindowDragRect=new  Rect(100,100,200,200);


	public int toolbarInt = 0;
	public string[] toolbarStrings = new string[] {"Toolbar1", "Toolbar2", "Toolbar3"};

	public Vector2 scrollPosition = Vector2.zero;


	public float hSbarValue;
	public float hSliderValue = 0.0F;
	public int  quitValue=0;

	public GUIStyle  GuiStyle1= new GUIStyle();
	public AudioClip  []AudipClips  =new  AudioClip[2]  ;
	public AudioClip  AudipClip1 = new AudioClip();
	public AudioSource    AS=new AudioSource();


	public void Awake() {
		Screen.showCursor = false;
	}
	// Use this for initialization
	void Start () {
		AudipClips[0]= (AudioClip)Resources.LoadAssetAtPath("Assets/Music1.mp3",typeof(AudioClip));
		Screen.SetResolution (800, 800, false);
		Debug.Log ("测试按钮程序开始！");
		print (GUI.depth);
	}
	
	// Update is called once per frame
	void Update () {

		if(1 ==  quitValue)
		Application.Quit();

	}

	/// <summary>
	/// Raises the GU event.
	/// </summary>
	void  OnGUI()
	{
		GUI.depth = 0;
		GUI.DrawTexture (new Rect (Input.mousePosition.x-10,Screen.height- Input.mousePosition.y-40,100,100), Textrue1, ScaleMode.ScaleToFit, true, 1.0F);
		
		GUI.depth = 1;
		if(GUILayout.Button("GUILayout按钮"))
		{
			print ("GUILayout 有按钮事件！");
			
			Application.Quit();
			//quitValue=1;
		}
		/*
		GUILayout.BeginArea (new Rect(300, 300, 500, 500));

		GUILayout.Label ("GUILayOut 标签!");

		GUILayout.EndArea();
*/
		#if false
		hSbarValue = GUI.HorizontalScrollbar(new Rect(25, 25, 100, 30), hSbarValue, 1.0F, 0.0F, 10.0F);
		hSliderValue = GUI.HorizontalSlider(new Rect(25, 60, 100, 30), hSliderValue, 0.0F, 10.0F);
		
		#endif

		#if false	

		
		if(GUI.Button(new Rect(100,100,100,30),new GUIContent("GUI  按钮 me", "This is the tooltip")))
		{
			print ("GUI 按钮事件!");
		}
		GUI.Label(new Rect(10, 40, 100, 40), GUI.tooltip);

		GUI.Label (new Rect(100,130,100,30),"GUI 标签!");
		GUI.Box(new Rect(100,160,100,30),"GUI 标签!");
		
		GUI.Label (new Rect (100, 110, 130, 30), stringToEdit);
		
		#endif

		//可拖动窗口
		WindowDragRect = GUI.Window(0,WindowDragRect,DoMyWindow,"可拖动窗口");

		#if false	
		stringToEdit = GUI.TextArea(new Rect(10, 10, 200, 100), stringToEdit, 200 );
		//stringToEdit = GUI.TextArea(new Rect(10, 10, 200, 100), stringToEdit, 200,GuiStyle1);

	//	stringToEdit = GUI.TextField (new Rect(210, 10, 200, 20), stringToEdit, 25);

		#endif
		
		#if  false	
		toolbarInt = GUI.Toolbar(new Rect(125, 25, 250, 30), toolbarInt, toolbarStrings);
		#endif




		#if false	
		
		scrollPosition = GUI.BeginScrollView(new Rect(10, 300, 100, 100), scrollPosition, new Rect(0, 0, 220, 200));
		GUI.Button(new Rect(0, 0, 100, 20), "Top-left");
		GUI.Button(new Rect(120, 0, 100, 20), "Top-right");
		GUI.Button(new Rect(0, 180, 100, 20), "Bottom-left");
		GUI.Button(new Rect(120, 180, 100, 20), "Bottom-right");
		GUI.EndScrollView();
		
		
		#endif
		#if flase
		 scrollPos = GUI.BeginScrollView(new Rect(10, 10, 100, 50), scrollPos, new Rect(0, 0, 220, 10));
		if (GUI.Button(new Rect(0, 0, 100, 20), "Go Right"))
			GUI.ScrollTo(new Rect(120, 0, 100, 20));
		
		if (GUI.Button(new Rect(120, 0, 100, 20), "Go Left"))
			GUI.ScrollTo(new Rect(0, 0, 100, 20));
		
	 	GUI.EndScrollView ();
		#endif



	}

	void  DoMyWindow(int  WindowID)
	{	
	
		
		if(GUI.Button (new Rect(0,0,100,30),"播放"))
		{	
			audio.clip=AudipClips[0];
			audio.Play();
		}	
		if(GUI.Button (new Rect(0,30,100,30),"暂停"))
		{
			audio.clip=AudipClips[0];
			audio.Pause();
		}	
		if(GUI.Button (new Rect(0,60,100,30),"停止"))
		{
			audio.clip=AudipClips[0];
			audio.Stop ();
		}
		GUI.DragWindow (new Rect (0,0,300,300));
			//GUI.DragWindow ();
	}

}
